package com.chlitina.store.modules.cash.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.modules.base.entity.Customer;
import com.chlitina.store.modules.sys.entity.Store;
@Entity
@Table(name = "store_consume_debt")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class StoreConsumeDebt  extends BaseEntity {
	private static final long serialVersionUID = 1L;
	private Long id; 		// 编号
	private Store store; 	// 店面
	private Customer customer;//会员
	private StoreConsume debtConsume;
	private StoreConsume refundConsume;
	private float debtMoney;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="STORE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Store getStore() {
		return store;
	}

	public void setStore(Store store) {
		this.store = store;
	}
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="CUSTOMER_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="DEBT_CONSUME_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public StoreConsume getDebtConsume() {
		return debtConsume;
	}

	public void setDebtConsume(StoreConsume debtConsume) {
		this.debtConsume = debtConsume;
	}
	@ManyToOne(cascade={CascadeType.REFRESH}, fetch = FetchType.LAZY) 
	@JoinColumn(name="REFUND_CONSUME_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public StoreConsume getRefundConsume() {
		return refundConsume;
	}

	public void setRefundConsume(StoreConsume refundConsume) {
		this.refundConsume = refundConsume;
	}
	
	@Column(name="DEBT_MONEY")
	public float getDebtMoney() {
		return debtMoney;
	}

	public void setDebtMoney(float debtMoney) {
		this.debtMoney = debtMoney;
	}
}
